<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Log;

// 应用公共文件

function encrypt($str){
    return '666';
}

/**
 * 日志记录
 * @param $msg
 * @param string $type
 */
function logger($msg,$type="log"){
    if($type=="info"){
        Log::info(date("Y-m-d H:i:s ").$msg);
    }elseif($type=="error"){
        Log::error(date("Y-m-d H:i:s ").$msg);
    }else{
        Log::log(date("Y-m-d H:i:s ").$msg);
    }
}

/**
 * 性能调试开始
 */
function debug_begin(){
    if(cache("sys_debug_flag")==1){
        debug("begin");
    }
}

/**
 * 性能调试结尾
 * @param string $fun
 */
function debug_end($fun=""){
    if(cache("sys_debug_flag")==1){
        debug("end");
        logger($fun."用时：".debug('begin','end').'s');
        logger($fun."占用内存：".debug('begin','end','m'));
    }
}